<template>
  <z-modal
    v-bind="modalOption"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
        <a-row>
          <a-col :span="12" >
            <a-form-model-item label="测评活动名称" prop = "name" >
              <!--<a-input  placeholder="请输入测评活动名称"  v-model.trim="form.name" disabled/>-->
              <ZSelectActivity v-model.trim="form.name" @change="(codes, selectRow) => selectActivity(this.form,selectRow)" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="测评活动描述" prop = "description" >
              <a-input v-model.trim="form.description" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="活动状态" prop="state">
              <z-dict-select-tag v-model="form.state" :disabled=true dictCode="BEISEN_ACTIVITY_STATE"/>
           </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="活动创建时间" prop = "activityCreateDate" >
              <a-input   v-model.trim="form.activityCreateDate" disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="展示名称" prop = "displayName" >
              <a-input  v-model.trim="form.displayName" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="是否展示" prop="displayState">
              <z-dict-select-tag v-model="form.displayState" :disabled="disableSubmit" dictCode="YESNO"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="租户" prop="tenantId">
              <z-dict-select-tag v-model="form.tenantId" :disabled="disableSubmit" dictCode="BEISEN_ACTIVITY_TENANT"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12" >
            <a-form-model-item label="排序" prop = "orderNum" >
              <a-input  placeholder="请输入排序数字"  v-model.trim="form.orderNum" type="number" :disabled="disableSubmit"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
import ZDictSelectTag from '@/components/dict/ZDictSelectTag'
import ZSelectActivity from '@/components/assessment/ZSelectActivity'
export default {
  name: 'ActivityModal',
  components: { ZDictSelectTag,ZSelectActivity },
  mixins: [ModalFormMixin],
  data() {
    return {
      validatorRules: {
        name: [{ required: true, message: '请选择测评活动' }],
        displayState: [{ required: true, message: '请选择展示状态' }],
        orderNum: [{ required: true, message: '请输入排序数字，数字越大活动越靠前展示' }],
        tenantId: [{ required: true, message: '请选择租户' }]
      },
      url: {
        add: '/assessment/activity/v1/add',
        edit: '/assessment/activity/v1/edit'
      }
    }
  },
  methods: {
    selectActivity(row, selectRow){
      row.bsActivityId = selectRow.activityId
      row.name = selectRow.activityName
      row.description = selectRow.activityDesc
      row.state = selectRow.state
      row.activityCreateDate = selectRow.createDate
    }
  }
}
</script>

